'''
msg: 
name: 
param: 
return: 
'''
from pathlib import Path
from typing import List

class FileManager:
    @staticmethod
    def get_input_files() -> List[Path]:
        """获取待处理文件列表"""
        return list(Path("data/input").glob("*.txt"))

    @staticmethod
    def create_output_dir(book_name: str) -> Path:
        """创建书籍输出目录"""
        path = Path("data/output") / book_name
        path.mkdir(parents=True, exist_ok=True)
        return path 

    @staticmethod
    def read_file(file_path: Path) -> str:
        """读取文件内容"""
        try:
            with open(file_path, 'r', encoding='utf-8') as f:
                return f.read()
        except Exception as e:
            raise IOError(f"无法读取文件 {file_path}: {str(e)}")

    @staticmethod
    def write_file(output_path: Path, content: str):
        """写入处理结果"""
        try:
            output_path.parent.mkdir(parents=True, exist_ok=True)
            with open(output_path, 'w', encoding='utf-8') as f:
                f.write(content)
        except Exception as e:
            raise IOError(f"无法写入文件 {output_path}: {str(e)}") 